home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Libris Britannia 4
/
science library(b).zip
/
science library(b)
/
PROGRAMM
/
CC_C
/
0574.ZIP
/
PUTW.ASM
< prev
next >
Wrap
Assembly Source File
|
1986-08-28
|
964b
|
70 lines
include compiler.inc
ttl PUTW, 1.03, 08-03-86 clr
;word output to stream
dseg
extrn _ftb:byte
cseg
xtfs <write,$strhand>
procdef putw, <<wrd, word>, <strm, ptr>>
locs <<fhdl, word>>
pushreg
pushds
callit $strhand <<strm,ptr>>
inc ax
jz seteof
dec ax
mov di,ax ;handle to DI
ldptr si, strm ;stream
test bl, 2
jz seteof ;not open for writing
test bl, 10h
jz ok ;no prev error
seteof: mov ax, -1
mov wrd, ax
jmp short fini
;
ok: mov ax, wrd
cmp ax, -1
jz fini
mov ax, wrd ;word to send
mov fhdl,ax
lea si,fhdl
mov bx,2
callit write,<<bx,reg>,<si,preg,ss>,<di,reg>>;
ldptr si, strm
cmp ax, 1
jge mkdrty
jnz seterr ;so set flags
or byte ptr 2[si], 08h ;so set EOF
jmp seteof
seterr:
or byte ptr 2[si], 10h ;so set ERROR
jmp seteof
;
mkdrty:
or byte ptr 2[si], 80h
fini:
mov ax, wrd ;return value
popds
pret
pend putw
finish
end